package cn.smbms.tools;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.core.convert.converter.Converter;

public class StringToDateConvter implements Converter<String, Date> {
	private String datePattern;

	public StringToDateConvter(String datePattern) {
		System.out.println("1.日期转换器是：" + datePattern);
		this.datePattern = datePattern;
	}

	@Override
	public Date convert(String s) {
		Date date = null;
		try {
			date = new SimpleDateFormat(datePattern).parse(s);
			System.out.println("2.日期转换器是：" + date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
	}
}